package org.example.guide.service;

import org.example.guide.domain.RealtimeInfo;
import org.example.guide.persistence.realtimeInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class realtimeInfoService {
    @Autowired
    realtimeInfoMapper realtimeinfoMapper;
    public List<RealtimeInfo> showrealtimeInfo(){
        return realtimeinfoMapper.selectAll();
    }

    public List<RealtimeInfo> searchrealtimeInfo(String keyword){
        return realtimeinfoMapper.selectByName(keyword);
    }

    public RealtimeInfo searchrealtimeInfoByID(int guideID){
        return realtimeinfoMapper.selectByID(guideID);
    }

    public void insertRealtimeInfo(RealtimeInfo realtimeInfo){
        realtimeinfoMapper.insert(realtimeInfo.getId(),realtimeInfo.getGuideID(),realtimeInfo.getVisitorCount(),realtimeInfo.getLocation(),realtimeInfo.getTimestamp());
    }

    public void deleteRealtimeInfo(int guideID){
        realtimeinfoMapper.delete(guideID);
    }
}
